package com.example.stu.controller;


import com.example.stu.entity.PageResult;
import com.example.stu.entity.PageStu;
import com.example.stu.entity.Result;
import com.example.stu.entity.res.StuChangePWD;
import com.example.stu.entity.res.StuSubmitVo;
import com.example.stu.pojo.Student;
import com.example.stu.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Date: 2021/2/24
 * @Author: 黄先军
 * @Description:
 */
@RestController
@RequestMapping("/student")
public class StudentInfoController {

    @Autowired
    private StudentService studentService;


    /**
     * 带条件的查询所有
     * @param pageStu
     * @return
     */
    @RequestMapping("findPage")
    public PageResult findall(@RequestBody PageStu pageStu) {
        return studentService.page(pageStu);
    }

    /**
     * 查找当前学生的数据，通过学生id查询
     * @param id
     * @return
     */
    @RequestMapping("findById")
    public Result findById(Integer id) {
        return studentService.findById(id);
    }

    /**
     * 查找当前学生的数据，通过学生学号查询
     * @param id
     * @return
     */
    @RequestMapping("findByStuId")
    public Result findByStuId(Integer id) {
        return studentService.findByStuId(id);
    }

    /**
     * 新增或者修改学生数据
     * @param student
     * @return
     */
    @RequestMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody Student student){
        return studentService.saveOrUpdate(student);
    }

    /**
     * 逻辑删除学生
     * @param id
     * @return
     */
    @RequestMapping("remove")
    public Result remove(Integer id){
        return studentService.remove(id);
    }

    /**
     * 学生修改提交自己的信息
     * @param stuSubmitVo
     * @return
     */
    @RequestMapping("tijiaoxinxi")
    public Result tijiaoxinxi(@RequestBody StuSubmitVo stuSubmitVo){
       return studentService.tijiaoxinxi(stuSubmitVo);
    }

    /**
     * 学生到校签到
     * @param stuSubmitVo
     * @return
     */
    @RequestMapping("signIn")
    public Result signIn(@RequestBody StuSubmitVo stuSubmitVo){
        return studentService.signIn(stuSubmitVo);
    }

    /**
     * 学生修改密码
     * @param stuChangePWD
     * @return
     */
    @RequestMapping("stuChangePWD")
    public Result stuChangePWD(@RequestBody StuChangePWD stuChangePWD){
        return studentService.stuChangePWD(stuChangePWD);
    }



}
